import requestModel from '@/utils/request-model'
import { useModelStore } from '@/stores/model'

// 获取模型服务器上的 NIFTI 文件（arraybuffer）
export const getNiftiByPath = (path) => {
  const modelStore = useModelStore()
  return requestModel({
    url: modelStore.modelInfo.serverUrl + path,
    method: 'get',
    responseType: 'arraybuffer'
  })
}

// 触发 BMS 分割任务，支持上传进度回调
export const segmentBms = (data, onUploadProgress) => {
  const modelStore = useModelStore()
  return requestModel({
    url: modelStore.modelInfo.serverUrl + '/bms/segment',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data,
    onUploadProgress
  })
}